package cn.dt70.service.impl;

import cn.dt70.dao.aqbCommodity.AqbCommodityMapper;
import cn.dt70.pojo.AqbCommodity;
import cn.dt70.service.AqbCommodityService;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class AqbCommodityServiceImpl implements AqbCommodityService {

    private static final Logger LOGGER = Logger.getLogger(AqbCommodityServiceImpl.class);

    @Resource
    private AqbCommodityMapper aqbCommodityMapper;

    @Override
    public List<AqbCommodity> getTuijian() {

        return null;
    }

    @Override
    public List<AqbCommodity> getShiti() {
        List<AqbCommodity> commodityList =new ArrayList<AqbCommodity>();
        try {
            commodityList = aqbCommodityMapper.getShiti();
            if(commodityList.size() <= 0){
                LOGGER.debug("AqbCommodityServiceImpl.getShiti 查询为空!");
            }else{
                LOGGER.debug("AqbCommodityServiceImpl.getShiti 查询成功!");
            }
        }catch (Exception e) {
            //e.printStackTrace();
            LOGGER.error("AqbCommodityServiceImpl.getShiti >>>"+e.getMessage());
        }

        return commodityList;
    }

    @Override
    public List<AqbCommodity> getHB() {
        List<AqbCommodity> commodityList = new ArrayList<AqbCommodity>();
        try{
            commodityList =aqbCommodityMapper.getHB();
            if(commodityList.size() <= 0){
                LOGGER.debug("AqbCommodityServiceImpl.getHB 查询为空!");
            }else{
                LOGGER.debug("AqbCommodityServiceImpl.getHB 查询成功!");
            }
        }catch (Exception e) {
            //e.printStackTrace();
            LOGGER.error("AqbCommodityServiceImpl.getHB >>>"+e.getMessage());
        }

        return  commodityList;
    }

    @Override
    public AqbCommodity getAqbCommodityBYAqbCommodity(int commodityId) {
        AqbCommodity aqbCommodity =new AqbCommodity();
        try {
            aqbCommodity = aqbCommodityMapper.getAqbCommodityBYAqbCommodity(commodityId);
        }catch (Exception e) {
            //e.printStackTrace();
            LOGGER.error("AqbCommodityServiceImpl.getAqbCommodityBYAqbCommodity >>>"+e.getMessage());
        }
        return aqbCommodity;
    }

    @Override
    public int getShitiCount(int commodityId) {
        int count = 0;
        try {
            System.out.println("aqbCommodityMapper.getShitiCount"+aqbCommodityMapper.getShitiCount(commodityId));
            count =aqbCommodityMapper.getShitiCount(commodityId);
        }catch (Exception e) {
            //e.printStackTrace();
            LOGGER.error("AqbCommodityServiceImpl.getShitiCount >>>"+e.getMessage());
        }
        return count;
    }

    @Override
    public Integer getHBtype(int commodityId) {
        int type = 0;
        try{
            type = aqbCommodityMapper.getHBtype(commodityId);
        }catch (Exception e) {
            //e.printStackTrace();
            LOGGER.error("AqbCommodityServiceImpl.getShitiCount >>>"+e.getMessage());
        }

        return type;
    }
}
